package org.tong.controller;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试nacos的配置服务区
 * curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=example&group=DEFAULT_GROUP&content=useLocalCache=true"
 */
@RestController
@RequestMapping("/config")
public class ConfigController {

    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
    private boolean useLoacalCache;

    @NacosValue(value = "${name:none}", autoRefreshed = true)
    private String name;

    @RequestMapping("/get")
    public String get() {
        return String.format("useLocalCache: %b, name:%s", useLoacalCache, name);
    }
}
